package queries;

import java.sql.SQLException;

import entitys.Category;
import enums.Result;

/**
 * Deletes the category from the ccrm.category
 * @author Dima
 *
 */
public class DeleteCategoryQuery {
	public static Result exe(Category category,java.sql.Connection conn) {
		
		
		java.sql.Statement stmt;
			
			try {
				stmt = conn.createStatement();
				stmt.executeUpdate("DELETE FROM ccrm.category WHERE id='"+category.getCategoryid()+"';");
				
				stmt = conn.createStatement();
				stmt.executeUpdate("DELETE FROM ccrm.productintype WHERE categoryID='"+ category.getCategoryid() +"';");

				return Result.OK;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				System.out.println("Error in delete");
				return Result.FAILED;
			}
			
	}

}
